package cn.weforward.task.weforward.view;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import cn.weforward.framework.ApiException;
import cn.weforward.protocol.doc.annotation.DocAttribute;
import cn.weforward.protocol.doc.annotation.DocObject;
import cn.weforward.task.Task;
import cn.weforward.task.weforward.util.JudgeState;

@DocObject(description = "任务视图")
public class TaskView {
	protected Task m_Task;
	
	public TaskView(Task task) {
		m_Task = task;
	}
	
	public static TaskView valueOf(Task task) {
		return null == task?null:new TaskView(task);
	}
	
	@DocAttribute(description = "任务id")
	public String getId() {
		//取得id的序列号部分
		return m_Task.getId().getOrdinal();
	}
	
	@DocAttribute(description = "任务标题")
	public String getTitle() {
		return m_Task.getTitle();
	}
	
	@DocAttribute(description = "父任务id")
	public String getFatherTaskId() {
		return m_Task.getFatherTaskId();
	}

	@DocAttribute(description = "任务优先级描述")
	public String getPriorityDesc() {
		return m_Task.getPriority().getName();
	}

	@DocAttribute(description = "任务状态描述")
	public String getStateDesc() {
		return m_Task.getState().getName();
	}
	@DocAttribute(description = "任务负责人")
	public String getManager() {
		return m_Task.getManager();
	}
	@DocAttribute(description = "任务处理人")
	public List<String> getHandlers() {
		return m_Task.getHandlers();
	}
	@DocAttribute(description = "任务跟进人")
	public List<String> getFollower() {
		return m_Task.getFollower();
	}
	@DocAttribute(description = "任务创建人")
	public String getCreator() {
		return m_Task.getCreator();
	}
	@DocAttribute(description = "任务标签")
	public String getTag() {
		return m_Task.getTag();
	}
	@DocAttribute(description = "任务期待开始时间")
	public Date getExpectedStartTime() {
		return m_Task.getExpectedStartTime();
	}
	@DocAttribute(description = "任务期待结束时间")
	public Date getExpectedEndTime() {
		return m_Task.getExpectedEndTime();
	}
	@DocAttribute(description = "任务创建时间")
	public Date getCreateTime() {
		return m_Task.getCreateTime();
	}
	@DocAttribute(description = "任务结束时间")
	public Date getEndTime() {
		return m_Task.getEndTime();
	}
	@DocAttribute(description = "能扭转的状态")
	public List<String> getChangeStateTips(){
		int currentState = m_Task.getState().id;
		return JudgeState.tips(currentState);
	}
	
}
